package com.zbkj.crmeb.task.cloud;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import com.xxl.job.core.handler.annotation.XxlJob;
import com.zbkj.crmeb.system.service.SystemAttachmentService;

@Component
@Configuration //读取配置
public class AsyncCloud {
    //日志
    private static final Logger logger = LoggerFactory.getLogger(AsyncCloud.class);

    @Value("${switch.task.AsyncCloudTask:true}")
    Boolean runable = true;

    @Autowired
    private SystemAttachmentService systemAttachmentService;

    @XxlJob("asyncCloud")
    public void init(){
        logger.info(" -------- execute  AsyncCloud ! runable: {}",runable);
        if(!runable){
            return;
        }

        try {
            systemAttachmentService.async();
        }catch (Exception e){
            e.printStackTrace();
            logger.error("AsyncCloud.task" + " | msg : " + e.getMessage());
        }
    }
}
